package ckgl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;

public class PljhdCtontroller extends Controller {

	static int g_infNumber = 10;
	static String kssj = null;
	static String jssj = null;


	public void index() {
		g_infNumber = 10;
		kssj = null;
		jssj = null;
		renderFreeMarker("/ckgl/pljhd.html");
	}

	/* 显示整体页面 */
	public void all() {
		if (getPara("kssj") != null || getPara("jssj") != null
			) {
			kssj = getPara("kssj");
			jssj = getPara("jssj");
		
		}
		if (getParaToInt("infNumber") != null) {
			g_infNumber = getParaToInt("infNumber");
		}
		if (jssj == null || kssj == null ) {
			Page<?> pljhd = Db.paginate(getParaToInt("pageNumber", 1),
					g_infNumber, "SELECT * ", "FROM pljhd ");

			Map<String, Object> map1 = new HashMap<String, Object>();
			map1.put("pljhd", pljhd);

			List<Object> data = new ArrayList<Object>();
			data.add(map1);
			renderJson(data);
		} else {
			Page<?> pljhd = Db.paginate(getParaToInt("pageNumber", 1),
					g_infNumber, "SELECT * ",
					"FROM pljhd where kssj between'" + kssj + "' and '" + jssj+ "' ");
			setAttr("pN", pljhd.getPageNumber());
			setAttr("tP", pljhd.getTotalPage());
			Map<String, Object> map1 = new HashMap<String, Object>();
			map1.put("pljhd", pljhd);
			List<Object> data = new ArrayList<Object>();
			data.add(map1);
			renderJson(data);
		}

	}
	
	public void luru(){
		
		String blrq=getPara("blrq");
		int id=getParaToInt("id");
		System.out.println("+++++++++"+id+blrq);
		Pljhd.dao.findById(id).set("blrq", blrq).update();
		redirect("/#pljhd");
		
		
	}
	
	
}
